package org.elj.jeasyexcel.structure.impl;

import java.util.ArrayList;
import java.util.List;

import org.elj.jeasyexcel.structure.ColumnHeader;
import org.elj.jeasyexcel.structure.Header;
import org.elj.jeasyexcel.structure.StructureFactory;
import org.elj.jeasyexcel.structure.Style;

public class HeaderImpl implements Header {

	/**
	 * Column headers
	 */
	private List<ColumnHeader> headers;
	private Style headerStyle;

	public HeaderImpl() {
		headers = new ArrayList<ColumnHeader>();
	}

	@Override
	public List<ColumnHeader> getHeaders() {
		return headers;
	}

	public void setHeaders(List<ColumnHeader> headers) {
		this.headers = headers;
	}

	public void setHeaders(String[] headers) {
		this.headers.clear();
		ColumnHeader columnHeader = null;
		for (String header : headers) {
			columnHeader = StructureFactory.getDefaultHeader(header);
			this.headers.add(columnHeader);
		}
	}

	@Override
	public Style getHeaderStyle() {
		if (headerStyle == null) {
			headerStyle = new StyleImpl();
		}
		return headerStyle;
	}

	@Override
	public void setHeaderStyle(Style style) {
		this.headerStyle = style;
	}

}
